package com.jeesite.modules.dataScreen.service;

import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson2.JSONObject;
import com.jeesite.modules.dataScreen.dao.PostalDataDao;
import com.jeesite.modules.dataScreen.dao.themedb.ThemeDbDao;
import com.jeesite.modules.dataScreen.web.vo.BasicPostalVO;
import com.jeesite.modules.dataScreen.web.vo.postal.PostMonthDataVo;
import com.jeesite.modules.dataScreen.web.vo.postal.PostalDataVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

import static com.jeesite.modules.dataScreen.web.vo.IndustryIndexFun.fun;

@Service
public class PostalService {

    @Autowired
    private PostalDataDao postalDataDao;
    @Resource
    private IndustryIndexService industryIndexService;
    @Resource
    private ThemeDbDao themeDbDao;


    public PostalDataVo getServiceNumber(int year) {
       return postalDataDao.getServiceNumber(year);
    }

    public PostalDataVo getPercentNumber(int year) {
        return postalDataDao.getPercentNumber(year);
    }

    public List<PostMonthDataVo> getExpressRevenue(int year) {

        return postalDataDao.getExpressRevenue(year);
    }

    public List<PostMonthDataVo> getMonthlyTrend(int year) {
        return postalDataDao.getMonthlyTrend(year);
    }

    public JSONObject comprehensiveInformation(String type) {

        JSONObject jsonObject = new JSONObject();
        if ("营业场所".equals(type)) {

            jsonObject.put("total", 22);
            jsonObject.put("data", 22);
            return jsonObject;
        } else if ("快递企业".equals(type)) {

            jsonObject.put("total", 22);
            jsonObject.put("data", 22);
            return jsonObject;
        } else if ("集邮市场".equals(type)) {

            jsonObject.put("total", 22);
            jsonObject.put("data", 22);
            return jsonObject;
        }

        return new JSONObject();
    }

    public BasicPostalVO basicPostal() {
        BasicPostalVO basicPostalVO = new BasicPostalVO();
        industryIndexService.assembly(basicPostalVO, false, CollUtil.toList(
                fun("申诉率", BasicPostalVO::getSsl),
                fun("邮政普遍服务营业场所名录", BasicPostalVO::getYzpbfwyecsml),
                fun("重庆市许可快递企业", BasicPostalVO::getCqsxkkdqy),
                fun("重庆市集邮市场", BasicPostalVO::getCqsjysc),
                fun("邮政行业寄递业务量", BasicPostalVO::getYzhyjdywl),
                fun("快递业务量", BasicPostalVO::getKdywl),
                fun("同城业务量", BasicPostalVO::getTcywl),
                fun("异地业务量", BasicPostalVO::getYdywl),
                fun("国际/港澳台快递业务量及同比增速", BasicPostalVO::getGjgatywl),
                fun("邮政行业业务收入", BasicPostalVO::getYzhyywsr),
                fun("快递业务收入及同比增速", BasicPostalVO::getKdywsrjtbzs)
        ));
        return basicPostalVO;
    }

    public List<String> expressEnterprise() {
       return themeDbDao.expressEnterprise();
    }

    public List<JSONObject> businessPremises() {
        List<JSONObject> data =themeDbDao.businessPremises();
        return data;
    }

    public List<JSONObject> businessPopUp(String name) {
//        Map<String, List<String>> nameToCodeMap = PostalCodeUtil.getNameToCodeMap();
        return themeDbDao.businessPopUp(name);

    }

    public List<JSONObject> enterprisePopUp(String name) {
        return themeDbDao.enterprisePopUp(name);
    }

    public List<JSONObject> brandClassification(String name) {
        return themeDbDao.brandClassification(name);
    }
}
